<template>
<!-- 这是支付头部导航栏 -->
  <div id="Payment_title_bar">
    <div class="my_shoppingTrolley">
      <div class="my_shoppingContent">
        <div class="my_shopText"><p><router-link to="/"><img src="../../public/img/logo10.png"></router-link></p>{{payTitle.title}}</div>
        <div class="my_user">
          <div class="ng_user_name">
            <el-dropdown >
              <span class="el-dropdown-link ng_span">
                <h5>{{userName}}</h5><i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="personal">{{$t("user.personal")}}</el-dropdown-item>
                <el-dropdown-item @click.native="myorder">{{$t("user.order")}}</el-dropdown-item>
                <el-dropdown-item @click.native="integ">{{$t("user.integ")}}</el-dropdown-item>
                <el-dropdown-item @click.native="changepass">{{$t("user.Change")}}</el-dropdown-item>
                <el-dropdown-item @click.native="logout">{{$t("user.out")}}</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
let Base64 = require('js-base64').Base64;
export default {
  props: {
    payTitle: {
      type: Object,
      required: true
    },
  },
  // props: ['payTitle'],
  data () {
    return {
      userName: '',
      shoppingBool: false,  // 识别是否从购物车页面过来
    }
  },
  methods: {
    // 个人信息
    personal() {
      // this.$emit('childValue', 0);
      this.$router.push({"path":"./personalDetails"});
    },
    // 我的订单
    myorder() {
      // this.$emit('childValue', 0);
      this.$router.push({"path":"/accountInformation/myorder"});
    },
    // 个人积分
    integ(){ 
      this.$router.push({"path":"./PointsExchange"})

    },
    // 修改密码
    changepass() {
      // this.$emit('childValue', 0);
      this.$router.push({"path":"./changePassword"});
    },
    // 退出登陆
    logout() {
      var _this = this;
      if(_this.shoppingBool) {
        _this.$emit('pass', _this.shoppingBool)
      } else {
        _this.$Cookie.removeCookie('strData'); //删除微信二维码的随机数
        _this.$Cookie.removeCookie('userLevel'); //删除用户等级
        _this.$store.commit('header', {nameBool: true, userName: ''});  //header组件，用户名，隐藏用户名，赋值空
        _this.$Cookie.removeCookie('token');    //删除token
        _this.$Cookie.removeCookie('userID');   //删除用户id
        _this.$store.commit('goods', []);
        _this.$router.push({"path":"/"});
      }
      
    },
  },
  created () {
    var _this = this;
    // 判断token,赋值用户名
    if(_this.$Cookie.getCookie('token') != undefined) {
        _this.userName = Base64.decode(_this.$Cookie.getCookie('userMobile'));
    } else {
      _this.$router.push({"path":"/"})
    };
    if(_this.payTitle.id == 'shopping') {
      _this.shoppingBool = true;
    }
  }
}
</script>

<style lang="less" scoped>
// 头部购物车标题
.my_shoppingTrolley {
  border-bottom: 2px solid #ff6700;
  font-size: 22px;
  height: 95px;
  line-height: 95px;
}
.my_shoppingContent {
  width: 70%;
  height: 100%;
  margin: auto;
  .my_shopText {
    float: left;
    height: 95px;
    p {
      display: inline-block;
      height: 100%;
      margin-right: 20px;
      vertical-align: middle;
      img {
        height: 100%;
      }
    }
  }
  .my_user {
    float: right;
    .ng_user_name {
      margin-left: 30px;
      margin-right: 7px;
      /deep/ .el-dropdown {
        display: block;
        height: 55px;
      }
      .ng_span {
        display: inline-block;
        margin-right: 18px;
        height: 30px;
        h5{
          text-align: center;
          margin: 0px;
          display: inline-block;
          width: 50px;
          text-transform: none;
          overflow:hidden;
          text-overflow:ellipsis;
          white-space: nowrap;
          color: black;
          font-size: 13px;
          font-family: inherit;
          font-weight: 500;
        }
      }
    }
  }
}
</style>